#ifndef _ROB_RFM70_h
#define _ROB_RFM70_h


#define RFM_DEBUG



//////////////////////////////////////////////////////////////////////
// Protocol declarations
//////////////////////////////////////////////////////////////////////

/*
#define TYPE_ACTOR              0
#define TYPE_SENSOR             1
#define TYPE_COMMANDER          2

#define MOT_STP 0x00
#define MOT_FWD 0x01
#define MOT_REV 0x02
#define MOT_BRK 0x03

*/

#define ID_XDIVIDER             0x01 // rcu wiichuck actor
#define ID_XZEROZONE            0x02 // rcu wiichuck actor
#define ID_YZEROZONE            0x03 // rcu wiichuck actor
#define ID_PITCHZEROZONE        0x04 // rcu wiichuck actor
#define ID_ROLLZEROZONE         0x05 // rcu wiichuck actor
#define ID_PITCHTOLERANCE       0x06 // rcu wiichuck actor
#define ID_ROLLTOLERANCE        0x07 // rcu wiichuck actor
#define ID_CHUCKACTORENABLER    0x08 // rcu wiichuck actor
#define ID_CHUCKACTORDELAY      0x09 // rcu wiichuck actor
#define ID_CHUCKSENSORENABLER   0x0a // rcu wiichuck actor
#define ID_CHUCKSENSORDELAY     0x0b // rcu wiichuck actor
#define ID_JOYX                 0x0c // rcu wiichuck sensor
#define ID_JOYY                 0x0d // rcu wiichuck sensor
#define ID_PITCH                0x0e // rcu wiichuck sensor
#define ID_ROLL                 0x0f // rcu wiichuck sensor
#define ID_BTNC                 0x10 // rcu wiichuck sensor
#define ID_BTNZ                 0x11 // rcu wiichuck sensor
#define ID_INITIALIZER          0x12 // rcu and rob actor. val is the prog nr for rob
#define ID_STATUSREQUESTER      0x13 // rcu and rob actor. val is the requested id. 0 = broadcast
#define ID_TELEMETRYENABLER     0x14 // rob telemetry actor
//#define ID_TELEMETRYDELAY       0x15 // rcu telemetry actor
#define ID_BATTERYSTATUS        0x16 // rob sensor
#define ID_SERVOPANTARGET       0x17 // rob telemetry actor
#define ID_SERVOTILTTARGET      0x18 // rob telemetry actor
//#define ID_SERVODELAY           0x19 // rob telemetry actor
#define ID_SERVOPANPOSITION     0x1a // rob sensor
#define ID_SERVOTILTPOSITION    0x1b // rob sensor
#define ID_ENGINESENSEDELAY     0x1c // rob telemetry actor
#define ID_ENGINELPOWER         0x1d // rob telemetry actor
#define ID_ENGINELDIRECTION     0x1e // rob telemetry actor
#define ID_ENGINERPOWER         0x1f // rob telemetry actor
#define ID_ENGINERDIRECTION     0x20 // rob telemetry actor
#define ID_ENGINELSPEED         0x21 // rob sensor
#define ID_ENGINERSPEED         0x22 // rob sensor
#define ID_IRBARENABLER        0x23 // rob telemetry actor
#define ID_IR1DISTANCE          0x24 // rob sensor
#define ID_IR2DISTANCE          0x25 // rob sensor
#define ID_IR3DISTANCE          0x26 // rob sensor
#define ID_IR4DISTANCE          0x27 // rob sensor
#define ID_IR5DISTANCE          0x28 // rob sensor
#define ID_PINGDISTANCE         0x29 // rob sensor
#define ID_PINGENABLER       0x2a // rob telemetry actor
#define ID_SOUNDPLAY            0x2b // rob telemetry actor
#define ID_CAM_ENABLER          0x2c // rob telemetry actor
#define ID_MOCS_TURN           0x2d // rob telemetry actor
//#define ID_MOCS_TURNL           0x2e // rob telemetry actor
#define ID_MOCS_DRIVESEC          0x2f // rob telemetry actor
//#define ID_MOCS_REVSEC          0x30 // rob telemetry actor
#define ID_CAVS_ENABLER         0x31 // rob telemetry actor
#define ID_FAVS_ENABLER         0x32 // rob telemetry actor
#define ID_HEARTBEAT            0x33 // Heartbeat-Message to rob fromrcu (or ddu)
#define ID_MOVEPANTILT          0x34 // rob telemetry actor
#define ID_BTNCZ                0x35 // rob telemetry actor
#define ID_TELEMETRY            0x36  // the telemetry sensor data from rob to rcu
#define ID_LIGHTS               0x37  // rob actor: lightsystem
#define ID_BTNS                 0x38  // rob sensor: buttonstate





class CRFM70RC {
  public:
    void Begin(uint8_t pinRFM);
    void update(void);
  
  private:
    RFM70 _rfm;
    byte _payload[RFM70_MAX_PACKET_LEN];    
    void dispatchRCUCmd(uint8_t * cmd, uint8_t len);
    void rcuTransmit(uint8_t * cmd_buf, uint8_t len);
#ifdef RFM_DEBUG
    void myDebug(uint8_t code);
#endif
};





extern CRFM70RC RFM70RC;


#endif // _ROB_RFM70_H
